﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DevExpress.XtraScheduler;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxScheduler;
using DevExpress.Web.ASPxScheduler.Internal;

public partial class scheduler_mySch_edit : SchedulerFormControl
{
    public bool CanShowReminders
    {
        get
        {
            return ((MyCustomContainer)Parent).Control.Storage.EnableReminders;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        //PrepareChildControls();
        tbSubject.Focus();

        //string strScript = "<script type='text/javascript'>";
        //strScript += "var oTdContainer = document.getElementById('tdRegular');";
        //strScript += "document.getElementById('_hidContent').value = oTdContainer.innerHTML;";
        //strScript += "alert(document.getElementById('_hidContent').value);";
        //strScript += "oTdContainer.innerHTML = '';";
        //strScript += "</script>";
        //Page.RegisterClientScriptBlock("hiddeBlock", strScript);

    }
    public override void DataBind()
    {
        ProxyDS.TypeName = "Ccit.OA.Scheduler.SchedulerBLL";
        ProxyDS.SelectMethod = "GetProxyList";

        base.DataBind();

        MyCustomContainer container = (MyCustomContainer)Parent;
        Appointment apt = container.Appointment;
        edtLabel.SelectedIndex = apt.LabelId;
        edtStatus.SelectedIndex = apt.StatusId;
        if (!Object.Equals(apt.ResourceId, Resource.Empty.Id))
            edtResource.Value = apt.ResourceId.ToString();
        else
            edtResource.Value = SchedulerIdHelper.EmptyResourceId;

        // AppointmentRecurrenceForm1.Visible = container.ShouldShowRecurrence;

        if (container.Appointment.HasReminder)
        {
            cbReminder.Value = container.Appointment.Reminder.TimeBeforeStart.ToString();
            chkReminder.Checked = true;
        }
        else
        {
            cbReminder.ClientEnabled = false;
        }

        btnOk.ClientSideEvents.Click = container.SaveHandler;
        btnCancel.ClientSideEvents.Click = container.CancelHandler;
        btnDelete.ClientSideEvents.Click = container.DeleteHandler;
        //btnDelete.Enabled = !container.IsNewAppointment;
    }

    protected override void PrepareChildControls()
    {
        MyCustomContainer container = (MyCustomContainer)Parent;
        ASPxScheduler control = container.Control;

        //AppointmentRecurrenceForm1.EditorsInfo = new EditorsInfo(control, control.Styles.FormEditors, control.Images.FormEditors, control.Styles.Buttons);
        base.PrepareChildControls();
    }
    protected override ASPxEditBase[] GetChildEditors()
    {
        ASPxEditBase[] edits = new ASPxEditBase[] {
			lblSubject, tbSubject,
			lblLocation, tbLocation,
			lblLabel, edtLabel,
			lblStartDate, edtStartDate,
			lblEndDate, edtEndDate,
			lblStatus, edtStatus,
			lblAllDay, chkAllDay,
			lblResource, edtResource,
			tbDescription, cbReminder,
            lblSchType,radPersonal,radProxy,lblSelProxy,ddlProxyPerson,
            lblPersonalSch,lblCompleteFlag,radCompleteN,radCompleteY,lblRemindType,
            cbkOnLine,cbkNow,cbkPhone,tbAdvTime,ddlRemindTimeType,
            cbkCircle,radDay,radWeek,radMonth,radYear,
            radEveryDay,tbEveryDay,radEveryWeekDay,tbWeekInterval,cbkWeekOne,
            cbkWeekTwo,cbkWeekThree,cbkWeekFour,cbkWeekFive,cbkWeekSix,
            cbkWeekSeven,radEveryMonth1,tbEveryMonth1,tbMonthDay1,radEveryMonth2,
            tbEveryMonth2,ddlMonthCount,ddlMonthWeek,radMonthCalender,radMonthLunar,
            radEveryYear1,ddlYearMonth1,tbYearDay,radEveryYear2,ddlYearMonth2,
            ddlYearCount,ddlYearWeek,radYearCalender,radYearLunar,ddlBeginDate,
            radCircle,tbRepeat,radEndDate,ddlEndDate
		};
        return edits;
    }
    protected override ASPxButton[] GetChildButtons()
    {
        ASPxButton[] buttons = new ASPxButton[] {
			btnOk, btnCancel, btnDelete
		};
        return buttons;
    }
}